home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Easy Applet Builder v1.7 / _SETUP.1 / Chat.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-11-06  |  4.4 KB  |  149 lines

  1. import java.applet.Applet;
  2. import java.awt.Button;
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.LayoutManager;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import java.net.URL;
  10. import java.util.EventObject;
  11.  
  12. public class Chat extends Applet implements ActionListener {
  13.    private String text;
  14.    // $FF: renamed from: wi int
  15.    private int field_0;
  16.    // $FF: renamed from: he int
  17.    private int field_1;
  18.    private int wib;
  19.    private int heb;
  20.    // $FF: renamed from: b java.awt.Button
  21.    private Button field_2;
  22.    private Color backCol;
  23.    private Color buttonCol;
  24.  
  25.    public String getAppletInfo() {
  26.       return "Name: Chat\r\nAuthor: Taiji Software";
  27.    }
  28.  
  29.    public void register() {
  30.       try {
  31.          URL u = new URL("http://www.taijisoftware.com");
  32.          ((Applet)this).getAppletContext().showDocument(u, "_blank");
  33.       } catch (Exception e) {
  34.          System.out.println(e);
  35.          this.stop();
  36.       }
  37.    }
  38.  
  39.    public void init() {
  40.       String codeBase = null;
  41.  
  42.       try {
  43.          codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
  44.          System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
  45.          codeBase = codeBase.toUpperCase();
  46.       } catch (Exception var9) {
  47.       }
  48.  
  49.       if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
  50.          String regCode = ((Applet)this).getParameter("registration_code");
  51.          if (regCode == null) {
  52.             regCode = ((Applet)this).getParameter("reg_domain");
  53.             if (regCode == null) {
  54.                this.register();
  55.             } else {
  56.                if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
  57.                   codeBase = "WWW." + codeBase;
  58.                } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
  59.                   codeBase = codeBase.substring(4);
  60.                }
  61.  
  62.                char[] chars = new char[codeBase.length()];
  63.                codeBase.getChars(0, codeBase.length(), chars, 0);
  64.                String key = new String("haricot");
  65.                char[] chars2 = new char[key.length()];
  66.                key.getChars(0, key.length(), chars2, 0);
  67.  
  68.                for(int i = 0; i < codeBase.length(); ++i) {
  69.                   int j;
  70.                   if (i >= key.length()) {
  71.                      j = i - key.length() * (i / key.length());
  72.                   } else {
  73.                      j = i;
  74.                   }
  75.  
  76.                   chars[i] += chars2[j];
  77.                   chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
  78.                }
  79.  
  80.                String res = new String(chars);
  81.                if (!res.equalsIgnoreCase(regCode)) {
  82.                   this.register();
  83.                }
  84.             }
  85.          } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
  86.             this.register();
  87.          }
  88.       }
  89.  
  90.       this.getParameters();
  91.       ((Container)this).setLayout((LayoutManager)null);
  92.       this.field_2 = new Button(this.text);
  93.       this.field_2.setSize(this.wib, this.heb);
  94.       this.field_2.addActionListener(this);
  95.       ((Container)this).add(this.field_2);
  96.       this.field_2.setLocation((this.field_0 - this.wib) / 2, (this.field_1 - this.heb) / 2);
  97.       ((Component)this).setBackground(this.getColor("background_color"));
  98.       this.field_2.setBackground(this.getColor("button_color"));
  99.    }
  100.  
  101.    public void stop() {
  102.    }
  103.  
  104.    public void getParameters() {
  105.       this.field_0 = ((Component)this).getSize().width;
  106.       this.field_1 = ((Component)this).getSize().height;
  107.       this.text = ((Applet)this).getParameter("text");
  108.       if (this.text == null) {
  109.          this.text = "Enter";
  110.       }
  111.  
  112.       String s = ((Applet)this).getParameter("button_width");
  113.       if (s != null) {
  114.          this.wib = Integer.parseInt(s);
  115.       } else {
  116.          this.wib = this.field_0;
  117.       }
  118.  
  119.       s = ((Applet)this).getParameter("button_height");
  120.       if (s != null) {
  121.          this.heb = Integer.parseInt(s);
  122.       } else {
  123.          this.heb = this.field_1;
  124.       }
  125.    }
  126.  
  127.    private Color getColor(String param) {
  128.       String s = ((Applet)this).getParameter(param);
  129.       if (s != null) {
  130.          if (s.substring(0, 1).equals("#")) {
  131.             s = s.substring(1);
  132.             int i = Integer.parseInt(s, 16);
  133.             return new Color(i);
  134.          } else {
  135.             return null;
  136.          }
  137.       } else {
  138.          return null;
  139.       }
  140.    }
  141.  
  142.    public void actionPerformed(ActionEvent event) {
  143.       if (((EventObject)event).getSource() instanceof Button) {
  144.          new Friends(this);
  145.       }
  146.  
  147.    }
  148. }
  149.